// pages/detail-page/detail-page.js
var app = getApp()
var ConstantData = require('../../../common/constant_data.js')
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
	
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function (options) {	
		var mac = options.mac;
    var that = this;		
		app.executeRequest(function (header) {
      wx.request({
        url: ConstantData.CONSTATNT_DATA.BASE_URL + '/leasePower/equDetail',
        header: header,
        method: 'post',
        data: {
          mac: mac
        },
        success: function (res) {
          let resData = res.data.data;
          if (resData) {
						that.setData(resData);
          }else {
						wx.showModal({
							title: '提示',
							content: '获取数据失败,请重新扫码!',
							showCancel:false,
							success (res) {
							}
						})
					}
        },
        fail: function (res) {
          console.log(res)
        }
      })
    });


	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function () {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function () {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function () {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function () {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function () {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function () {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function () {

	},

	chooseTime: function(event){
		let time = event.currentTarget.dataset.val;
		let status = event.currentTarget.dataset.status;

		if (status == '1') {
			this.setData({choosedTimes:time});
		}
	},

	startMathine: function(event) {
		if (this.data.userAudit == 0) {
			this.setData({showNotify:1});
		}
	},

	closeNotify: function(event) {
		this.setData({showNotify:0});
	}
})